package com.dkm.biz.ou.domain;

import java.math.BigDecimal;
import java.util.Date;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.dkm.biz.domain.AbstractDomain;
import com.dkm.base.core.helper.SpringHelper;
import com.dkm.biz.ou.persistence.dao.MeFinanceDao;
import com.dkm.biz.ou.persistence.entity.MeFinancePo;
import com.dkm.biz.ou.persistence.entity.MeFinancePoStatus;
import com.dkm.biz.ou.repository.MeFinanceRepository;

/**
 * 对象功能:t_me_finance 领域对象实体
 * 开发公司:dkm.com
 * 开发人员:ZHH
 * 创建时间:2017-07-21 17:38:39
 */
@SuppressWarnings("serial")
@Service
@Scope("prototype")
public class MeFinance extends AbstractDomain<String, MeFinancePo>{
	 @Resource
	 private MeFinanceRepository meFinanceRepository;
	 
	 private MeFinanceDao meFinanceDao = null;

	protected void init(){
		meFinanceDao = SpringHelper.getBean(MeFinanceDao.class);
		setDao(meFinanceDao);
	}

	public void createMeFianceById(String userId) {
		for(MeFinancePoStatus meFinancePoStatus : MeFinancePoStatus.values()){
			MeFinancePo meFinancePo = new MeFinancePo();
			meFinancePo.setPartyId(userId);
			meFinancePo.setRemainingTotal(new BigDecimal("0"));
			meFinancePo.setCreateTime(new Date());
			meFinancePo.setType(meFinancePoStatus.toString());
			
		   MeFinance meFinance =meFinanceRepository.newInstance(meFinancePo);
		   meFinance.create();
		}
	}	 
	 
}
